<?php

namespace App\Providers;

use App\Models\Address;
use App\Models\BatchWithdraw;
use App\Models\Brand;
use App\Models\Channel;
use App\Models\Comment;
use App\Models\Config;
use App\Models\ConfigStorm;
use App\Models\GoldCharge;
use App\Models\GoldProduct;
use App\Models\GoldRound;
use App\Models\GoldSeed;
use App\Models\OrderRefund;
use App\Models\OrderRefundNego;
use App\Models\Vendor;
use App\Models\Withdraw;
use App\Models\Material;
use App\Models\CouponRecord;
use App\Observers\AddressObserver;
use App\Observers\BatchWithdrawObserver;
use App\Observers\BrandObserver;
use App\Observers\CommentObserver;
use App\Observers\ConfigObserver;
use App\Observers\ConfigStormObserver;
use App\Observers\GoldChargeObserver;
use App\Observers\GoldProductObserver;
use App\Observers\GoldSeedObserver;
use App\Observers\OrderRefundNegoObserver;
use App\Observers\OrderRefundObserver;
use App\Observers\PosterObserver;
use App\Observers\VendorObserver;
use App\Observers\WithdrawObserver;
use Carbon\Carbon;
use App\Models\User;
use App\Models\Order;
use App\Models\Product;
use App\Models\Category;
use App\Models\ProductSku;
use App\Models\AttributeKey;
use App\Models\VipPurchase;
use App\Models\AttributeGroup;
use App\Observers\UserObserver;
use App\Observers\OrderObserver;
use App\Observers\MaterialObserver;
use App\Observers\ProductObserver;
use App\Observers\CategoryObserver;
use App\Observers\ProductSkuObserver;
use App\Observers\AttributeKeyObserver;
use App\Observers\CouponRecordObserver;
use Closure;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use App\Observers\AttributeGroupObserver;
use App\Observers\VipPurchaseObserver;
use Illuminate\Http\Resources\Json\JsonResource;
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
	    if ($this->app->environment('local')) {
		    $this->app->register(IdeHelperServiceProvider::class);
	    }
    }
    
    public function boot()
    {
	    Carbon::setLocale('zh');
	    JsonResource::withoutWrapping();
	    Schema::defaultStringLength(191);
    	$this->bindHttp();
	    $this->bindObservers();
    }
    
    protected function bindHttp()
    {
	    if (! $this->app->environment('local')) {
		    URL::forceScheme('https'); 
	    }
    }
    
    protected function bindObservers()
    {
    	Config::observe(ConfigObserver::class);
    	ConfigStorm::observe(ConfigStormObserver::class);
	    User::observe(UserObserver::class);
	    Address::observe(AddressObserver::class);
	    Category::observe(CategoryObserver::class);
	    Brand::observe(BrandObserver::class);
	    AttributeGroup::observe(AttributeGroupObserver::class);
	    AttributeKey::observe(AttributeKeyObserver::class);
	    Product::observe(ProductObserver::class);
	    ProductSku::observe(ProductSkuObserver::class);
	    Order::observe(OrderObserver::class);
	    OrderRefund::observe(OrderRefundObserver::class);
	    OrderRefundNego::observe(OrderRefundNegoObserver::class);
	    Comment::observe(CommentObserver::class);
	    Withdraw::observe(WithdrawObserver::class);
	    BatchWithdraw::observe(BatchWithdrawObserver::class);
	    Vendor::observe(VendorObserver::class);
	    GoldCharge::observe(GoldChargeObserver::class);
	    GoldSeed::observe(GoldSeedObserver::class);
	    GoldProduct::observe(GoldProductObserver::class);
	    VipPurchase::observe(VipPurchaseObserver::class);
	    Material::observe(MaterialObserver::class);
	    CouponRecord::observe(CouponRecordObserver::class);
	    
    }
}
